package cn.wxl.mymeituan.activity;

import android.os.Bundle;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import cn.wxl.mymeituan.R;
import cn.wxl.mymeituan.bean.FoodBean;
import com.bumptech.glide.Glide;



public class FoodActivity extends AppCompatActivity {
    private FoodBean foodBean;
    private TextView food_name, food_monthSale, food_price;
    private ImageView food_image;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_food);
        //从店铺详情界面传递过来的菜的数据
        foodBean = (FoodBean) getIntent().getSerializableExtra("food");
        initView();
        setData();
    }
    /**
     * 初始化界面控件
     */
    private void initView() {
        food_name = (TextView) findViewById(R.id.food_name);
        food_monthSale = (TextView) findViewById(R.id.food_monthSale);
        food_price = (TextView) findViewById(R.id.food_price);
        food_image = (ImageView) findViewById(R.id.food_image);
    }
    /**
     * 设置界面数据
     */
    private void setData() {
        if (foodBean == null) return;
        food_name.setText(foodBean.getFoodName());
        food_monthSale.setText("月售" + foodBean.getFoodMonthSale());
        food_price.setText("￥" + foodBean.getPrice());
        Glide.with(this)
                .load(foodBean.getFoodImage())
                .into(food_image);
    }
}
